
//
//  ZYThreeGoodParentsCell.m
//  优学荟管理系统
//
//  Created by edz on 2017/12/13.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "ZYThreeGoodParentsCell.h"
#import "ZYThreeGoodParentsModel.h"
@implementation ZYThreeGoodParentsCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpSuperView];
    }
    
    
    return self;
    
}

- (void)assignByZYThreeGoodParentsModel:(ZYThreeGoodParentsModel *)model{
    
    
    
    BOOL isUp = [NSString isBlankString:model.petName];
    
    if (isUp) {
        
        self.nameLabel.text = @"";
    }else{
        
        self.nameLabel.text = [NSString stringWithFormat:@"%@",model.petName];
    }
    
    
    
    BOOL isUpTow = [NSString isBlankString:model.phone];
    
    if (isUpTow) {
        
        self.phoneLabel.text = @"";
    }else{
        
        self.phoneLabel.text = [NSString stringWithFormat:@"%@",model.phone];
        
    }
    
    
    BOOL isUpThree = [NSString isBlankString:model.avatar];
    
    if (isUpThree) {
        
        self.photoImageView.image = [UIImage imageNamed:@"bg_picture_default"];
    }else{
        
        
        [self.photoImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"bg_picture_default"]];
        
    }
    
    
    
    
}



- (void)setUpSuperView{
    
    
    self.photoImageView = [UIImageView new];
    self.photoImageView.image = [UIImage imageNamed:@"bg_picture_default"];
    [self.contentView addSubview:self.photoImageView];
    
    
    self.nameLabel = [UILabel new];
    self.nameLabel.font = [UIFont systemFontOfSize:16];
    self.nameLabel.textColor = ColorRGB(0, 0, 0);
    [self.contentView addSubview:self.nameLabel];
    
    
    self.phoneLabel = [UILabel new];
    self.phoneLabel.font = [UIFont systemFontOfSize:14];
    self.phoneLabel.textColor = ColorRGB(102, 102, 102);
    [self.contentView addSubview:self.phoneLabel];
    
    
    self.staudentListButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.staudentListButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.staudentListButton setTitle:@"学生列表" forState:(UIControlStateNormal)];
    [self.staudentListButton setBackgroundImage:[UIImage imageNamed:@"btn_student"] forState:(UIControlStateNormal)];
    [self.staudentListButton setTitleColor:ColorRGB(255, 255, 255) forState:(UIControlStateNormal)];
    [self.contentView addSubview:self.staudentListButton];
    
    self.deleteButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.deleteButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.deleteButton setTitle:@"删除" forState:(UIControlStateNormal)];
     [self.deleteButton setBackgroundImage:[UIImage imageNamed:@"btn_deleted"] forState:(UIControlStateNormal)];
    [self.deleteButton setTitleColor:ColorRGB(153,153,153) forState:(UIControlStateNormal)];
    [self.contentView addSubview:self.deleteButton];
    
    
    
    [self.photoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.offset(kScreenWidth *30/750);
        make.top.offset(kScreenHeight *47/1334);
        make.width.height.offset(kScreenWidth *96/750);
    }];
    
    
    self.nameLabel.text = @"dddd";
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.photoImageView.mas_right).offset(kScreenWidth *30/750);
        make.top.offset(kScreenHeight *40/1334);
    }];
    
    
    self.phoneLabel.text = @"134556677788";
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(kScreenHeight *20/1334);
    }];
    
    
    
    [self.staudentListButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(kScreenHeight *34/1334);
        make.right.equalTo(self).offset(-kScreenWidth *30/750);
    }];
    
    
    [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.staudentListButton.mas_bottom).offset(kScreenHeight *20/1334);
        make.right.equalTo(self.staudentListButton);
    }];
    
    
    UILabel *lineLabel = [UILabel new];
    lineLabel.backgroundColor = ColorRGB(245, 245, 245);
    [self.contentView addSubview:lineLabel];
    
    
    
    
    [lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(self.deleteButton.mas_bottom).offset(kScreenHeight *40/1334);
        make.width.offset(kScreenWidth);
        make.height.offset(kScreenHeight *30/1334);
    }];
    

    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.mas_equalTo(lineLabel).offset(0);
    }];
    
    
}






































@end
